home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / rw_hashmap.z / rw_hashmap
Encoding:
Text File  |  1998-10-30  |  21.3 KB  |  463 lines

  1.  
  2.  
  3.  
  4. rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp((((3333CCCC++++++++))))                                              rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      rw_hashmap - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/rwstl/hashmap.h>
  13.           rw_hashmap<K,V,Hash,EQ> map;
  14.  
  15.  
  16.  
  17.  
  18. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  19.      Class rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp<<<<KKKK,,,,VVVV,,,,HHHHaaaasssshhhh,,,,EEEEQQQQ>>>> maintains a collection of mappings between
  20.      KKKK and VVVV, implemented as a hash table of ppppaaaaiiiirrrr<<<<ccccoooonnnnsssstttt KKKK,,,,VVVV>>>> .  Pairs with
  21.      duplicate keys are not allowed.  Two pairs having duplicate keys is the
  22.      result of the EEEEQQQQ comparison, applied to the first element of each, is
  23.      TTTTRRRRUUUUEEEE.  Since this is a vvvvaaaalllluuuueeee based collection, objects are ccccooooppppiiiieeeedddd into
  24.      and out of the collection.  As with all classes that meet the ANSI
  25.      aaaassssssssoooocccciiiiaaaattttiiiivvvveeee ccccoooonnnnttttaaaaiiiinnnneeeerrrr specification, rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp provides for iterators
  26.      that reference its elements.  Operations that alter the contents of
  27.      rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp may invalidate other iterators that reference the container.
  28.      Since the contents of rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp are in pseudo-random order, the only
  29.      iterator ranges that will usually make sense are the results of calling
  30.      eeeeqqqquuuuaaaallll____rrrraaaannnnggggeeee((((kkkkeeeeyyyy)))), and the entire range from bbbbeeeeggggiiiinnnn(((()))) to eeeennnndddd(((()))).
  31.  
  32. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  33.      None
  34.  
  35. PPPPuuuubbbblllliiiicccc TTTTyyyyppppeeeeddddeeeeffffssss
  36.               typedef K                  key_type;
  37.           typedef Hash               key_hash;
  38.           typedef EQ                 key_equal;
  39.           typedef pair<K,V>          value_type; // or ... "const K"
  40.           typedef ((((uuuunnnnssssiiiiggggnnnneeeedddd))))         size_type; //from rw_slist
  41.           typedef ((((iiiinnnntttt))))              difference_type; // from rw_slist
  42.           typedef ((((vvvvaaaalllluuuueeee____ttttyyyyppppeeee&&&&))))      reference;
  43.           typedef ((((ccccoooonnnnsssstttt vvvvaaaalllluuuueeee____ttttyyyyppppeeee&&&&)))) const_reference; //from rw_slist
  44.  
  45.  
  46.      Iterators over rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp<<<<KKKK,,,,VVVV,,,,HHHHaaaasssshhhh,,,,EEEEQQQQ>>>> are forward iterators.
  47.  
  48.               typedef ((((ssssccccooooppppeeeedddd IIIItttteeeerrrraaaattttoooorrrr))))      iterator;
  49.           typedef ((((ssssccccooooppppeeeedddd CCCCoooonnnnssssttttIIIItttteeeerrrraaaattttoooorrrr))))  const_iterator;
  50.  
  51.  
  52.  
  53. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  54.               rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp<K,V,Hash,EQ>(size_type sz = 1024,
  55.                                   const Hash& h = Hash(),
  56.                                   const EQ& eq = EQ());
  57.  
  58.  
  59.      Construct an empty rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp<<<<KKKK,,,,VVVV,,,,HHHHaaaasssshhhh,,,,EEEEQQQQ>>>> with sssszzzz slots, using hhhh as the
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp((((3333CCCC++++++++))))                                              rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.      hash object, and eeeeqqqq as the equality comparator.
  75.  
  76.               rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp<K,V,Hash,EQ>(const rw_hashmap<K,V,Hash,EQ>& map);
  77.  
  78.  
  79.      Construct an rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp<<<<KKKK,,,,VVVV,,,,HHHHaaaasssshhhh,,,,EEEEQQQQ>>>> which is a copy of mmmmaaaapppp.  Each
  80.      element from mmmmaaaapppp will be copied into self.
  81.  
  82.               rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp<K,V,Hash,EQ>(const_iterator first,
  83.                                   const_iterator bound
  84.                                   size_type sz=1024,
  85.                                   const Hash& h = Hash(),
  86.                                   const EQ& eq = EQ());
  87.  
  88.  
  89.      Construct an rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp<<<<KKKK,,,,VVVV,,,,HHHHaaaasssshhhh,,,,EEEEQQQQ>>>> with sssszzzz slots, using hhhh as the hash
  90.      object, and eeeeqqqq as the equality comparator, containing a copy of each pair
  91.      referenced by the range starting with ffffiiiirrrrsssstttt and bounded by bbbboooouuuunnnndddd.
  92.  
  93.               rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp<K,V,Hash,EQ>(const value_type* first,
  94.                                   const value_type* bound
  95.                                   size_type sz=1024,
  96.                                   const Hash& h = Hash(),
  97.                                   const EQ& eq = EQ());
  98.  
  99.  
  100.      Construct an rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp<<<<KKKK,,,,VVVV,,,,HHHHaaaasssshhhh,,,,EEEEQQQQ>>>> with sssszzzz slots, using hhhh as the hash
  101.      object, and eeeeqqqq as the equality comparator, containing a copy of each pair
  102.      referenced by the range starting with ffffiiiirrrrsssstttt and bounded by bbbboooouuuunnnndddd.  If
  103.      there are items in the range for which the KKKK parts of the pairs match EEEEQQQQ,
  104.      then only the first such item will be inserted into self.
  105.  
  106. PPPPuuuubbbblllliiiicccc DDDDeeeessssttttrrrruuuuccccttttoooorrrr
  107.               ~~~~rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp<K,V,Hash,EQ>();
  108.  
  109.  
  110.      The destructor releases the memory used by the container's
  111.      implementation.
  112.  
  113. PPPPuuuubbbblllliiiicccc OOOOppppeeeerrrraaaattttoooorrrrssss
  114.               rw_hashmap<K,V,Hash,EQ>&
  115.           ooooppppeeeerrrraaaattttoooorrrr====(const rw_hashmap<K,V,Hash,EQ>& rhs);
  116.  
  117.  
  118.      Sets self to have the same capacity, HHHHaaaasssshhhh and EEEEQQQQ as rrrrhhhhssss, removes all
  119.      self's current contents, and replaces them with copies of the elements in
  120.      rrrrhhhhssss.
  121.  
  122.               bool
  123.           ooooppppeeeerrrraaaattttoooorrrr========(const rw_hashmap<K,V,Hash,EQ> & rhs) const;
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp((((3333CCCC++++++++))))                                              rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.      Returns true if self and rrrrhhhhssss have the same number of elements, and for
  141.      each vvvvaaaalllluuuueeee____ttttyyyyppppeeee in self, there is a vvvvaaaalllluuuueeee____ttttyyyyppppeeee in rrrrhhhhssss that has a first
  142.      part for which the EEEEQQQQ object in self returns true, and a second part for
  143.      which ooooppppeeeerrrraaaattttoooorrrr========(((()))) returns true.  The need to test both parts means that
  144.      this operator is slightly slower than the method eeeeqqqquuuuaaaallll____bbbbyyyy____kkkkeeeeyyyyssss(((())))
  145.      described below.
  146.  
  147.               V&
  148.           ooooppppeeeerrrraaaattttoooorrrr[[[[]]]](const key_type& key);
  149.  
  150.  
  151.      Returns a reference to the VVVV part of a pair held in self which has a part
  152.      EEEEQQQQ to kkkkeeeeyyyy, either by finding such a pair, or inserting one (in which case
  153.      the reference is to an instance of VVVV created by its default constructor).
  154.  
  155. AAAAcccccccceeeessssssssoooorrrrssss
  156.               iterator
  157.           bbbbeeeeggggiiiinnnn();
  158.  
  159.  
  160.      The iterator returned references the first item in self.  If self is
  161.      empty, the iterator is equal to eeeennnndddd(((()))).  Note that because items are
  162.      stored in pseudo-random order, this iterator might reference any item
  163.      that has been stored in self.
  164.  
  165.               const_iterator
  166.           bbbbeeeeggggiiiinnnn() const;
  167.  
  168.  
  169.      The iterator returned references the first item in self.  If self is
  170.      empty, the iterator is equal to eeeennnndddd(((()))).  Note that because items are
  171.      stored in pseudo-random order, this iterator might reference any item
  172.      that has been stored in self.
  173.  
  174.               iterator
  175.           eeeennnndddd();
  176.  
  177.  
  178.      The iterator returned marks the location "off the end" of self.  It may
  179.      not be dereferenced.
  180.  
  181.               const_iterator
  182.           eeeennnndddd() const;
  183.  
  184.  
  185.      The iterator returned marks the location "off the end" of self.  It may
  186.      not be dereferenced.
  187.  
  188.               pair<const_iterator, const_iterator>
  189.           eeeeqqqquuuuaaaallll____rrrraaaannnnggggeeee(const key_type key) const;
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp((((3333CCCC++++++++))))                                              rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.      Returns ppppaaaaiiiirrrr<<<<ccccoooonnnnsssstttt____iiiitttteeeerrrraaaattttoooorrrr,,,, ccccoooonnnnsssstttt____iiiitttteeeerrrraaaattttoooorrrr>>>>((((lllloooowwwweeeerrrr____bbbboooouuuunnnndddd((((kkkkeeeeyyyy)))),,,,
  207.      uuuuppppppppeeeerrrr____bbbboooouuuunnnndddd((((kkkkeeeeyyyy)))))))).  Upper and lower bound have special meaning for hash-
  208.      based collections.  See discussion elsewhere.
  209.  
  210.               pair<iterator, iterator>
  211.           eeeeqqqquuuuaaaallll____rrrraaaannnnggggeeee(const key_type key);
  212.  
  213.  
  214.      Returns ppppaaaaiiiirrrr<<<<iiiitttteeeerrrraaaattttoooorrrr,,,, iiiitttteeeerrrraaaattttoooorrrr>>>>((((lllloooowwwweeeerrrr____bbbboooouuuunnnndddd((((kkkkeeeeyyyy)))),,,, uuuuppppppppeeeerrrr____bbbboooouuuunnnndddd((((kkkkeeeeyyyy)))))))).
  215.      Upper and lower bound have special meaning for hash-based collections.
  216.      See discussion elsewhere.
  217.  
  218.               const_iterator
  219.           lllloooowwwweeeerrrr____bbbboooouuuunnnndddd(const key_type& key) const;
  220.  
  221.  
  222.      Returns the lower bound of kkkkeeeeyyyy in self.  This has a special meaning for
  223.      hash-based collections.  See discussion elsewhere.
  224.  
  225.               iterator
  226.           lllloooowwwweeeerrrr____bbbboooouuuunnnndddd(const key_type& key);
  227.  
  228.  
  229.      Returns the lower bound of kkkkeeeeyyyy in self.  This has a special meaning for
  230.      hash-based collections.  See discussion elsewhere.
  231.  
  232.               const_iterator
  233.           uuuuppppppppeeeerrrr____bbbboooouuuunnnndddd(const key_type& key) const;
  234.  
  235.  
  236.      Returns the upper bound of kkkkeeeeyyyy in self.  This has a special meaning for
  237.      hash-based collections.  See discussion elsewhere.
  238.  
  239.               iterator
  240.           uuuuppppppppeeeerrrr____bbbboooouuuunnnndddd(const key_type& key);
  241.  
  242.  
  243.      Returns the upper bound of kkkkeeeeyyyy in self.  This has a special meaning for
  244.      hash-based collections.  See discussion elsewhere.
  245.  
  246. CCCCoooonnnnsssstttt PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  247.               size_type
  248.           ccccaaaappppaaaacccciiiittttyyyy() const;
  249.  
  250.  
  251.      Returns the number of slots in the hash table that self uses.
  252.  
  253.               bool
  254.           eeeemmmmppppttttyyyy() const;
  255.  
  256.  
  257.      Returns ttttrrrruuuueeee if self is empty.
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp((((3333CCCC++++++++))))                                              rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp((((3333CCCC++++++++))))
  269.  
  270.  
  271.  
  272.               float
  273.           ffffiiiillllllll____rrrraaaattttiiiioooo() const;
  274.  
  275.  
  276.      Returns the result of calculating ssssiiiizzzzeeee(((())))////ccccaaaappppaaaacccciiiittttyyyy(((()))).
  277.  
  278.               size_type
  279.           ssssiiiizzzzeeee() const;
  280.  
  281.  
  282.      Returns the number of pairs currently held in self.
  283.  
  284. MMMMuuuuttttaaaattttoooorrrrssss
  285.               void
  286.           cccclllleeeeaaaarrrr();
  287.  
  288.  
  289.      A synonym for eeeerrrraaaasssseeee((((bbbbeeeeggggiiiinnnn(((()))),,,,eeeennnndddd(((())))))));;;;
  290.  
  291.               size_type
  292.           eeeerrrraaaasssseeee(const key_type& key);
  293.  
  294.  
  295.      If there is a pair in self for which the first part is EEEEQQQQ to kkkkeeeeyyyy, that
  296.      pair is removed, and 1111 is returned.  Otherwise, 0000 is returned.
  297.  
  298.               iterator
  299.           eeeerrrraaaasssseeee(iterator iter);
  300.  
  301.  
  302.      Removes the element referenced by iiiitttteeeerrrr and returns an iterator
  303.      referencing the "next" element.  If iiiitttteeeerrrr does not reference an item in
  304.      self, the result is undefined.
  305.  
  306.               iterator
  307.           eeeerrrraaaasssseeee(iterator first, iterator bound);
  308.  
  309.  
  310.      Removes each element in the range which begins with ffffiiiirrrrsssstttt and is bound by
  311.      bbbboooouuuunnnndddd.  Returns an iterator referencing bbbboooouuuunnnndddd.  If ffffiiiirrrrsssstttt does not
  312.      reference an item in self (and if ffffiiiirrrrsssstttt and bbbboooouuuunnnndddd are not equal), the
  313.      effect is undefined.
  314.  
  315.               pair<iterator,bool>
  316.           iiiinnnnsssseeeerrrrtttt(const value_type& val);
  317.  
  318.  
  319.      If there is no pair in self with first part EEEEQQQQ to the first part of vvvvaaaallll
  320.      then inserts vvvvaaaallll, returning a pair with an iterator referencing the new
  321.      element and true.  Otherwise, returns a pair with an iterator referencing
  322.      the matching vvvvaaaalllluuuueeee____ttttyyyyppppeeee and false.
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp((((3333CCCC++++++++))))                                              rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp((((3333CCCC++++++++))))
  335.  
  336.  
  337.  
  338.               size_type
  339.           iiiinnnnsssseeeerrrrtttt(iterator ignore, const value_type& val);
  340.  
  341.  
  342.      If there is no pair in self with first part EEEEQQQQ to the first part of vvvvaaaallll
  343.      then inserts vvvvaaaallll, returning 1111.  Otherwise, does nothing and returns 0000.
  344.      Note that the first argument is provided only for conformance with the
  345.      ANSI aaaassssssssoooocccciiiiaaaattttiiiivvvveeee ccccoooonnnnttttaaaaiiiinnnneeeerrrr specification, and is ignored by the method,
  346.      since hash table look up can be done in constant time.
  347.  
  348.               size_type
  349.           iiiinnnnsssseeeerrrrtttt(const value_type* first, const value_type* bound);
  350.  
  351.  
  352.      For each element in the range beginning with ffffiiiirrrrsssstttt and bounded by bbbboooouuuunnnndddd,,,,
  353.      if there is no pair in self with first part EEEEQQQQ to the first part of that
  354.      element, the element is copied into self, or if there is such a pair, the
  355.      element is skipped.  Returns the number of elements inserted.
  356.  
  357.               size_type
  358.           iiiinnnnsssseeeerrrrtttt(const_iterator first, const_iterator bound);
  359.  
  360.  
  361.      For each element in the range beginning with ffffiiiirrrrsssstttt and bounded by bbbboooouuuunnnndddd,,,,
  362.      if there is no pair in self with first part EEEEQQQQ to the first part of that
  363.      element, the element is copied into self, or if there is such a pair, the
  364.      element is skipped.  Returns the number of elements inserted.
  365.  
  366.               void
  367.           sssswwwwaaaapppp(rw_hashmap<K,V,Hash,EQ>& other);
  368.  
  369.  
  370.      Exchanges the contents of self with ooootttthhhheeeerrrr including the HHHHaaaasssshhhh and EEEEQQQQ
  371.      objects.  This method does not copy or destroy any of the items exchanged
  372.      but exchanges the underlying hash tables.
  373.  
  374. SSSSppppeeeecccciiiiaaaallll MMMMeeeetttthhhhooooddddssss ffffoooorrrr MMMMaaaappppssss
  375.               size_type
  376.           ccccoooouuuunnnntttt(const key_type& key) const;
  377.  
  378.  
  379.      Returns 1111 if self contains a pair with its first element EEEEQQQQ to kkkkeeeeyyyy, else
  380.      0000.
  381.  
  382.               bool
  383.           eeeeqqqquuuuaaaallll____bbbbyyyy____kkkkeeeeyyyyssss(const rw_hashmap<K,V,Hash,EQ>& rhs) const;
  384.  
  385.  
  386.      Returns true if self and rrrrhhhhssss have the same size, and if for each
  387.      vvvvaaaalllluuuueeee____ttttyyyyppppeeee in self, there is a vvvvaaaalllluuuueeee____ttttyyyyppppeeee in rrrrhhhhssss such that the EEEEQQQQ object
  388.      in self returns true when called for the first parts of those pairs.
  389.      Note that this method does not compare the VVVV (second) part of the pair of
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp((((3333CCCC++++++++))))                                              rrrrwwww____hhhhaaaasssshhhhmmmmaaaapppp((((3333CCCC++++++++))))
  401.  
  402.  
  403.  
  404.      the items, so it will run slightly faster than ooooppppeeeerrrraaaattttoooorrrr========(((()))).
  405.  
  406.               const_iterator
  407.           ffffiiiinnnndddd(const key_type& key) const;
  408.  
  409.  
  410.      Returns a const_iterator referencing the pair with kkkkeeeeyyyy as its first
  411.      element if such a pair is contained in self, else returns eeeennnndddd(((()))).
  412.  
  413.               iterator
  414.           ffffiiiinnnndddd(const key_type& key);
  415.  
  416.  
  417.      Returns an iterator referencing the pair with kkkkeeeeyyyy as its first element,
  418.      if such a pair is contained in self, else returns eeeennnndddd(((()))).
  419.  
  420.               void
  421.           rrrreeeessssiiiizzzzeeee(size_type sz);
  422.  
  423.  
  424.      Resizes self's hash table to have sssszzzz slots; and re-hashes all self's
  425.      elements into the new table.  Can be very expensive if self holds many
  426.      elements.
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.